package com.beardedcoder.utils.power;

import java.util.Date;

import android.content.Context;
import android.net.wifi.WifiManager;

public class FeaturesWifi implements PowerFeatures {
	
	private WifiManager mWifiManager = null;;

	public FeaturesWifi(Context context) {
		mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
	}

	@Override
	public boolean isActive() throws Exception {
		return mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED || mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLING;
	}

	@Override
	public void deactivate() {
		mWifiManager.setWifiEnabled(false);
	}

	@Override
	public void activate() {
		mWifiManager.setWifiEnabled(true);
	}

	@Override
	public void toggleState() {
		try {
			mWifiManager.setWifiEnabled(!isActive());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public void setDeactivateAt(Date time) {
	}

	@Override
	public void setActivateAt(Date time) {
	}

}
